<?php
echo $header;
echo $column_left;
echo $column_right;
$width_content = '98%';
if (($column_left) && ($column_right)) {
    $width_content = '48%';
} elseif (($column_left) || ($column_right)) {
    $width_content = '73%';
}
?>
<div class="content" style="width:<?php echo $width_content; ?>"><?php echo $content_top; ?>
    <div class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
            <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
        <?php } ?>
    </div>
    <ul data-role="listview" data-divider-theme="a" data-inset="true">
        <li data-role="list-divider"><h1><?php echo $heading_title; ?></h1></li>
    </ul><br />
    <?php if ($success) { ?>
        <div class="success"><?php echo $success; ?></div>
    <?php } 
    
    if ($products) {
        $keyN = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i');
        $productN = sizeof($products);
        ?>
        <div class="compare-info">
            <ul data-role="listview" data-divider-theme="a" data-inset="true">
                <li data-role="list-divider"><?php echo $text_product; ?></li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_name; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><a href="<?php echo $products[$product['product_id']]['href']; ?>"><?php echo $products[$product['product_id']]['name']; ?></a></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_image; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php if ($products[$product['product_id']]['thumb']) { ?>
                                    <img src="<?php echo $products[$product['product_id']]['thumb']; ?>" alt="<?php echo $products[$product['product_id']]['name']; ?>" />
                                <?php } ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_price; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php if ($products[$product['product_id']]['price']) { ?>
                                    <?php if (!$products[$product['product_id']]['special']) { ?>
                                        <?php echo $products[$product['product_id']]['price']; ?>
                                    <?php } else { ?>
                                        <span class="price-old"><?php echo $products[$product['product_id']]['price']; ?></span> <span class="price-new"><?php echo $products[$product['product_id']]['special']; ?></span>
                                    <?php } ?>
                                <?php } ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_model; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php echo $products[$product['product_id']]['model']; ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_manufacturer; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php echo $products[$product['product_id']]['manufacturer']; ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_availability; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php echo $products[$product['product_id']]['availability']; ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_rating; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><img src="catalog/view/theme/tablet/image/stars-<?php echo $products[$product['product_id']]['rating']; ?>.png" alt="<?php echo $products[$product['product_id']]['reviews']; ?>" /><br />
                                <?php echo $products[$product['product_id']]['reviews']; ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_summary; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php echo $products[$product['product_id']]['description']; ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_weight; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php echo $products[$product['product_id']]['weight']; ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"><?php echo $text_dimension; ?></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php echo $products[$product['product_id']]['length']; ?> x <?php echo $products[$product['product_id']]['width']; ?> x <?php echo $products[$product['product_id']]['height']; ?></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <?php foreach ($attribute_groups as $attribute_group) { ?>
                    <li data-role="list-divider"><?php echo $attribute_group['name']; ?></li>
                    <?php foreach ($attribute_group['attribute'] as $key => $attribute) { ?>
                        <li>
                            <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                                <div class="ui-block-a"><?php echo $attribute['name']; ?></div>
                                <?php $n = 1;
                                foreach ($products as $product) { ?>
                                    <?php if (isset($products[$product['product_id']]['attribute'][$key])) { ?>
                                        <div class="name ui-block-<?php echo $keyN[$n]; ?>"><?php echo $products[$product['product_id']]['attribute'][$key]; ?></div>
                                    <?php } else { ?>
                                        <div class="name ui-block-<?php echo $keyN[$n]; ?>"></div>
                                    <?php } ?>
                                    <?php ++$n;
                                } ?>
                            </div>
                        </li>
                    <?php } ?>
                <?php } ?>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?>"><a data-theme="c" data-role="button" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
                <li>
                    <div class="ui-grid-<?php echo $keyN[$productN - 1]; ?>">
                        <div class="ui-block-a"></div>
                        <?php $n = 1;
                        foreach ($products as $product) { ?>
                            <div class="name ui-block-<?php echo $keyN[$n]; ?> remove"><a data-role="button" href="<?php echo $product['remove']; ?>" class="button"><?php echo $button_remove; ?></a></div>
                            <?php ++$n;
                        } ?>
                    </div>
                </li>
            </ul>
        </div>
        <div class="buttons">
            <div class="right"><a data-role="button" href="<?php echo $continue; ?>" class="button"><span><?php echo $button_continue; ?></span></a></div>
        </div>
    <?php } else { ?>
        <div class="content"><?php echo $text_empty; ?></div>
        <div class="buttons">
            <div class="right"><a data-role="button" href="<?php echo $continue; ?>" class="button"><span><?php echo $button_continue; ?></span></a></div>
        </div>
    <?php } ?>
    <?php echo $content_bottom; ?>
</div>
<?php echo $footer; ?>